{% extends 'base.html' %}

{% block title %}修改密码{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0">
                        <i class="fas fa-lock"></i> 修改密码
                    </h4>
                </div>
                <div class="card-body">
                    <div class="card mb-3 border-info">
                        <div class="card-header bg-info text-white">
                            <h6 class="mb-0">
                                <i class="fas fa-info-circle"></i> 安全提示
                            </h6>
                        </div>
                        <div class="card-body">
                            <p class="mb-0">您当前使用的是临时密码，为了账户安全，请立即设置新密码。</p>
                        </div>
                    </div>
                    
                    {% if temp_password %}
                    <div class="card mb-3 border-info">
                        <div class="card-header bg-info text-white">
                            <h6 class="mb-0">
                                <i class="fas fa-clock"></i> 临时密码信息
                            </h6>
                        </div>
                        <div class="card-body">
                            <div class="row mb-1">
                                <div class="col-4"><strong>创建时间：</strong></div>
                                <div class="col-8">{{ temp_password.created_at|date:"Y-m-d H:i" }}</div>
                            </div>
                            <div class="row mb-1">
                                <div class="col-4"><strong>过期时间：</strong></div>
                                <div class="col-8">{{ temp_password.expires_at|date:"Y-m-d H:i" }}</div>
                            </div>
                            <div class="row mb-0">
                                <div class="col-4"><strong>创建者：</strong></div>
                                <div class="col-8">{{ temp_password.created_by.username }}</div>
                            </div>
                        </div>
                    </div>
                    {% endif %}
                    <form method="post">
                        {% csrf_token %}
                        
                        <div class="mb-3">
                            <label for="{{ form.new_password1.id_for_label }}" class="form-label">新密码</label>
                            {{ form.new_password1 }}
                            {% if form.new_password1.errors %}
                                <div class="text-danger">
                                    {% for error in form.new_password1.errors %}
                                        <small>{{ error }}</small><br>
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="card mt-2 border-info">
                                <div class="card-header bg-info text-white">
                                    <h6 class="mb-0">
                                        <i class="fas fa-shield-alt"></i> 密码要求
                                    </h6>
                                </div>
                                <div class="card-body">
                                    <ul class="mb-0">
                                        <li>密码不能与您的其他个人信息太相似。</li>
                                        <li>密码必须包含至少 8 个字符。</li>
                                        <li>密码不能是常用密码。</li>
                                        <li>密码不能全部为数字。</li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        
                        <div class="mb-3">
                            <label for="{{ form.new_password2.id_for_label }}" class="form-label">确认新密码</label>
                            {{ form.new_password2 }}
                            {% if form.new_password2.errors %}
                                <div class="text-danger">
                                    {% for error in form.new_password2.errors %}
                                        <small>{{ error }}</small><br>
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                        
                        <div class="d-grid">
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-save"></i> 修改密码
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
.form-control {
    border-radius: 0.375rem;
}

.btn {
    border-radius: 0.375rem;
}

.card {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}
</style>
{% endblock %}